home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
linux-bo
/
etherboo.000
/
etherboo
/
etherboot-2.0
/
patches
/
netboot-freebsd-compiles-with-linux.patch
< prev
next >
Wrap
Text File
|
1995-09-14
|
17KB
|
538 lines
diff -u -r -N netboot-freebsd-orig/Makefile.linux netboot-freebsd/Makefile.linux
--- netboot-freebsd-orig/Makefile.linux Thu Jan 1 01:00:00 1970
+++ netboot-freebsd/Makefile.linux Sat Sep 9 00:23:05 1995
@@ -0,0 +1,85 @@
+# Makefile,v 1.4 1994/12/31 17:16:49 jkh Exp
+#
+# Makefile for NETBOOT
+#
+# Basic Options:
+# -DASK_BOOT - Ask "Boot from Network (Y/N) ?" at startup
+# -DROMSIZE - Size of EPROM - Must be set (even for .COM files)
+# -DRELOC - Relocation address (usually 0x90000)
+#
+# NS8390 Options:
+# -DINCLUDE_WD - Include Western Digital/SMC support
+# -DINCLUDE_NE - Include NE1000/NE2000 support
+# -DINCLUDE_3COM - Include 3c503 support
+# -D_3COM_USE_AUI - Disable transceiver on 3c503 by default
+# -DNE_BASE - Base I/O address for NE1000/NE2000
+# -DNE_NOSCAN - Do not try to automatically find NEx000 I/O address
+# -D_3COM_BASE - Base I/O address for 3c503
+# -DWD_DEFAULT_MEM- Default memory location for WD/SMC cards
+# XXX nothing depends on this Makefile so you must run `make clean' after
+# changing an option.
+#
+
+PROG= nb8390.com nb3c509.com nb8390.rom nb3c509.rom
+# Order is very important on the SRCS line for this prog
+SRCS= start2.S main.c misc.c bootmenu.c rpc.c
+OBJS= start2.o main.o misc.o bootmenu.o rpc.o
+ROBJS= start2.ro main.o misc.o bootmenu.o rpc.o
+
+CFLAGS= -O2 -DNFS -DROMSIZE=${ROMSIZE} -DRELOC=${RELOCADDR}
+CFLAGS+= -fstrength-reduce -fomit-frame-pointer -m386
+# NS8390= -DINCLUDE_WD -DWD_DEFAULT_MEM=0xD0000
+NS8390+= -DINCLUDE_NE
+# NS8390+= -DINCLUDE_3COM -D_3COM_BASE=0x300
+CLEANFILES= ${OBJS}
+CLEANFILES+= nb8390.bin nb3c509.bin nb8390c.bin nb3c509c.bin
+CLEANFILES+= makerom start2.ro 3c509.o ns8390.o
+LDFLAGS+= -N -Ttext ${RELOCADDR} -e _start -nostdlib
+
+ROMSIZE=16384
+RELOCADDR=0x90000
+
+.SUFFIXES: .ro
+
+all: ${PROG}
+
+clean:
+ ${RM} -rf ${CLEANFILES}
+
+.S.ro:
+ ${CC} ${CFLAGS} -DBOOTROM -o $@ -c $<
+
+.S.o:
+ ${CC} ${CFLAGS} -o $@ -c $<
+
+ns8390.o: ns8390.c
+ ${CC} $(CFLAGS) $(NS8390) -o $@ -c $<
+
+makerom: makerom.c
+ ${CC} -o $@ -DROMSIZE=${ROMSIZE} ./makerom.c
+
+nb8390.rom: makerom start2.ro ${ROBJS} ns8390.o
+ ${LD} ${LDFLAGS} -o nb8390.bin ${ROBJS} ns8390.o
+ strip nb8390.bin
+ size nb8390.bin
+ objdump -k -q -o ${RELOCADDR} nb8390.bin >$@
+ ./makerom $@
+
+nb3c509.rom: makerom start2.ro ${ROBJS} 3c509.o
+ ${LD} ${LDFLAGS} -o nb3c509.bin ${ROBJS} 3c509.o
+ strip nb3c509.bin
+ size nb3c509.bin
+ objdump -k -q -o ${RELOCADDR} nb3c509.bin >$@
+ ./makerom $@
+
+nb8390.com: makerom start2.ro ${OBJS} ns8390.o
+ ${LD} ${LDFLAGS} -o nb8390c.bin ${OBJS} ns8390.o
+ strip nb8390c.bin
+ size nb8390c.bin
+ objdump -k -q -o ${RELOCADDR} nb8390c.bin >$@
+
+nb3c509.com: start2.o ${OBJS} 3c509.o
+ ${LD} ${LDFLAGS} -o nb3c509c.bin ${OBJS} 3c509.o
+ strip nb3c509c.bin
+ size nb3c509c.bin
+ objdump -k -q -o ${RELOCADDR} nb3c509c.bin >$@
diff -u -r -N netboot-freebsd-orig/linuxdef.h netboot-freebsd/linuxdef.h
--- netboot-freebsd-orig/linuxdef.h Thu Jan 1 01:00:00 1970
+++ netboot-freebsd/linuxdef.h Fri Sep 8 15:20:33 1995
@@ -0,0 +1,203 @@
+/*
+ * This file contains definitions for compiling the FreeBSD-based code
+ * on a Linux system. It has been collected from misc. header files of
+ * the FreeBSD distribution. Therefore the following copyright conditions
+ * apply
+ */
+
+/*-
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#ifndef __LINUXDEF_H__
+#define __LINUXDEF_H__
+
+#include <asm/byteorder.h>
+#include <asm/io.h>
+#include <sys/types.h>
+
+/* Linux reverses the order of the parameters, so change the macros */
+#undef outb
+#define outb(port,val) \
+((__builtin_constant_p((port)) && (port) < 256) ? \
+ __outbc((val),(port)) : \
+ __outb((val),(port)))
+#undef outw
+#define outw(port,val) \
+((__builtin_constant_p((port)) && (port) < 256) ? \
+ __outwc((val),(port)) : \
+ __outw((val),(port)))
+
+#define IFNAMSIZ 16
+#define NGROUPS_MAX 16 /* max supplemental group id's */
+#define NGROUPS NGROUPS_MAX /* max number groups */
+#define NFSX_V2FH 32
+#define MNAMELEN 90 /* length of buffer for returned name*/
+#define MAXHOSTNAMELEN 256 /* max hostname size */
+#define SOCK_STREAM 1 /* stream socket */
+#define SOCK_DGRAM 2 /* datagram socket */
+#define NFSMNT_SOFT 0x00000001 /* soft mount (hard is default) */
+#define NFSMNT_WSIZE 0x00000002 /* set write size */
+#define NFSMNT_RSIZE 0x00000004 /* set read size */
+#define NFSMNT_INT 0x00000040 /* allow interrupts on hard mount */
+#define NFSMNT_RESVPORT 0x00008000 /* Allocate a reserved port */
+#define NFSERR_PERM 1
+#define NFSERR_NOENT 2
+#define NFSERR_ACCES 13
+#define AF_UNSPEC 0 /* unspecified */
+#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
+#define CLSIZELOG2 0
+#define CLSIZE (1 << CLSIZELOG2)
+#define PAGE_SHIFT 12
+#define NBPG (1 << PAGE_SHIFT) /* bytes/page */
+#define CLOFSET (CLSIZE*NBPG-1) /* for clusters, like PGOFSET */
+#define BOOTINFO_VERSION 1
+#define N_BIOS_GEOM 8
+#define NODEV (dev_t)(-1) /* non-existent device */
+#define OMAGIC 0407 /* old impure format */
+#define NMAGIC 0410 /* read-only text */
+#define ZMAGIC 0413 /* demand load format */
+#define QMAGIC 0314 /* "compact" demand load format */
+#define __LDPGSZ 4096
+
+#define N_GETMAGIC(ex) \
+ ( (ex).a_midmag & 0xffff )
+#define N_GETMAGIC_NET(ex) \
+ (ntohl((ex).a_midmag) & 0xffff)
+#define N_BADMAG(ex) \
+ (N_GETMAGIC(ex) != OMAGIC && N_GETMAGIC(ex) != NMAGIC && \
+ N_GETMAGIC(ex) != ZMAGIC && N_GETMAGIC(ex) != QMAGIC && \
+ N_GETMAGIC_NET(ex) != OMAGIC && N_GETMAGIC_NET(ex) != NMAGIC && \
+ N_GETMAGIC_NET(ex) != ZMAGIC && N_GETMAGIC_NET(ex) != QMAGIC)
+#define N_TXTOFF(ex) \
+ (N_GETMAGIC(ex) == ZMAGIC ? __LDPGSZ : (N_GETMAGIC(ex) == QMAGIC || \
+ N_GETMAGIC_NET(ex) == ZMAGIC) ? 0 : sizeof(struct exec))
+
+struct sockaddr {
+ u_char sa_len; /* total length */
+ u_char sa_family; /* address family */
+ char sa_data[14]; /* actually longer; address value */
+};
+
+struct in_addr {
+ u_long s_addr;
+};
+
+struct sockaddr_in {
+ u_char sin_len;
+ u_char sin_family;
+ u_short sin_port;
+ struct in_addr sin_addr;
+ char sin_zero[8];
+};
+
+struct ifaliasreq {
+ char ifra_name[IFNAMSIZ]; /* if name, e.g. "en0" */
+ struct sockaddr ifra_addr;
+ struct sockaddr ifra_broadaddr;
+ struct sockaddr ifra_mask;
+};
+
+struct nfs_args {
+ struct sockaddr *addr; /* file server address */
+ int addrlen; /* length of address */
+ int sotype; /* Socket type */
+ int proto; /* and Protocol */
+ u_char *fh; /* File handle to be mounted */
+ int fhsize; /* Size, in bytes, of fh */
+ int flags; /* flags */
+ int wsize; /* write size in bytes */
+ int rsize; /* read size in bytes */
+ int readdirsize; /* readdir size in bytes */
+ int timeo; /* initial timeout in .1 secs */
+ int retrans; /* times to retry send */
+ int maxgrouplist; /* Max. size of group list */
+ int readahead; /* # of blocks to readahead */
+ int leaseterm; /* Term (sec) of lease */
+ int deadthresh; /* Retrans threshold */
+ char *hostname; /* server's name */
+};
+
+struct ucred {
+ u_short cr_ref; /* reference count */
+ uid_t cr_uid; /* effective user id */
+ short cr_ngroups; /* number of groups */
+ gid_t cr_groups[NGROUPS]; /* groups */
+};
+
+struct nfs_diskless {
+ struct ifaliasreq myif; /* Default interface */
+ struct sockaddr_in mygateway; /* Default gateway */
+ struct nfs_args swap_args; /* Mount args for swap file */
+ u_char swap_fh[NFSX_V2FH]; /* Swap file's file handle */
+ struct sockaddr_in swap_saddr; /* Address of swap server */
+ char swap_hostnam[MNAMELEN]; /* Host name for mount pt */
+ int swap_nblks; /* Size of server swap file */
+ struct ucred swap_ucred; /* Swap credentials */
+ struct nfs_args root_args; /* Mount args for root fs */
+ u_char root_fh[NFSX_V2FH]; /* File handle of root dir */
+ struct sockaddr_in root_saddr; /* Address of root server */
+ char root_hostnam[MNAMELEN]; /* Host name for mount pt */
+ long root_time; /* Timestamp of root fs */
+ char my_hostnam[MAXHOSTNAMELEN]; /* Client host name */
+};
+
+struct bootinfo {
+ unsigned int bi_version;
+ unsigned char *bi_kernelname;
+ struct nfs_diskless *bi_nfs_diskless;
+ /* End of fields that are always present. */
+#define bi_endcommon bi_n_bios_used
+ unsigned int bi_n_bios_used;
+ unsigned long bi_bios_geom[N_BIOS_GEOM];
+ unsigned int bi_size;
+ unsigned char bi_memsizes_valid;
+ unsigned char bi_pad[3];
+ unsigned long bi_basemem;
+ unsigned long bi_extmem;
+ unsigned long bi_symtab;
+ unsigned long bi_esymtab;
+};
+
+struct exec {
+ unsigned long a_midmag; /* flags<<26 | mid<<16 | magic */
+ unsigned long a_text; /* text segment size */
+ unsigned long a_data; /* initialized data size */
+ unsigned long a_bss; /* uninitialized data size */
+ unsigned long a_syms; /* symbol table size */
+ unsigned long a_entry; /* entry point */
+ unsigned long a_trsize; /* text relocation size */
+ unsigned long a_drsize; /* data relocation size */
+};
+
+#endif
diff -u -r -N netboot-freebsd-orig/main.c netboot-freebsd/main.c
--- netboot-freebsd-orig/main.c Tue May 30 10:55:00 1995
+++ netboot-freebsd/main.c Fri Sep 8 10:59:08 1995
@@ -31,6 +31,10 @@
/**************************************************************************
MAIN - Kick off routine
**************************************************************************/
+#ifdef __linux
+_main() {main();}
+#endif
+
main()
{
int c;
diff -u -r -N netboot-freebsd-orig/makerom.c netboot-freebsd/makerom.c
--- netboot-freebsd-orig/makerom.c Wed Apr 12 20:48:00 1995
+++ netboot-freebsd/makerom.c Fri Sep 8 11:12:46 1995
@@ -24,10 +24,12 @@
exit(2);
}
bzero(rom, ROMSIZE);
+#ifndef __linux
if (lseek(fd, (off_t)32, SEEK_SET) < 0) {
perror("lseek error");
exit(2);
}
+#endif
if (read(fd, rom, ROMSIZE) < 0) {
perror("read error");
exit(2);
diff -u -r -N netboot-freebsd-orig/netboot.h netboot-freebsd/netboot.h
--- netboot-freebsd-orig/netboot.h Wed Apr 12 20:48:00 1995
+++ netboot-freebsd/netboot.h Thu Sep 7 19:54:14 1995
@@ -6,6 +6,9 @@
**************************************************************************/
+#ifdef __linux
+#include "linuxdef.h"
+#else
#include <sys/types.h>
#include <a.out.h>
#include <netdb.h>
@@ -18,6 +21,7 @@
#include <nfs/nfsdiskless.h>
#include <machine/bootinfo.h>
#include <machine/cpufunc.h>
+#endif
#define ESC 0x1B
diff -u -r -N netboot-freebsd-orig/ns8390.c netboot-freebsd/ns8390.c
--- netboot-freebsd-orig/ns8390.c Tue May 30 10:55:00 1995
+++ netboot-freebsd/ns8390.c Sat Sep 9 00:23:55 1995
@@ -270,6 +270,7 @@
eth_bmem = (char *)0; /* No shared memory */
eth_asic_base = NE_BASE + NE_ASIC_OFFSET;
eth_nic_base = NE_BASE;
+ scanaddr:
eth_vendor = VENDOR_NOVELL;
eth_flags = FLAG_PIO;
eth_memsize = MEM_16384;
@@ -295,7 +296,18 @@
outb(eth_nic_base + D8390_P0_PSTOP, MEM_32768);
eth_pio_write(test, 16384, sizeof(test));
eth_pio_read(16384, testbuf, sizeof(test));
- if (!bcompare(testbuf, test, sizeof(test))) return (0);
+ if (!bcompare(testbuf, test, sizeof(test))) {
+#ifndef NE_NOSCAN
+ static int idx=0,base[5]={0x320,0x340,0x360,0x300,0};
+ skip:
+ if ((eth_nic_base = base[idx++]) != 0) {
+ if (eth_nic_base == NE_BASE) goto skip;
+ eth_asic_base = eth_nic_base + NE_ASIC_OFFSET;
+ goto scanaddr;
+ }
+#endif
+ return (0);
+ }
}
eth_pio_read(0, romdata, 16);
printf("\r\nNE1000/NE2000 base 0x%x, addr ", eth_nic_base);
diff -u -r -N netboot-freebsd-orig/start2.S netboot-freebsd/start2.S
--- netboot-freebsd-orig/start2.S Mon Oct 17 00:00:00 1994
+++ netboot-freebsd/start2.S Fri Sep 8 11:04:11 1995
@@ -12,6 +12,9 @@
* executed from an address it was not linked to. Code must be pic and
* 32 bit sensitive until things are fixed up.
*/
+#ifdef __linux
+_romstart:
+#endif
#ifdef BOOTROM
.word 0xaa55 /* bios extension signature */
.byte (ROMSIZE>>9) /* no. of 512B blocks */
@@ -35,7 +38,11 @@
.byte 0xa3 /* MOV %ax, 0x302 */
.word 0x302
.byte 0xb8 /* MOV $_start-RELOCADDR, %ax */
+#ifndef __linux
.word (_start-RELOC)
+#else
+ .word (_start-_romstart)
+#endif
.byte 0xa3 /* MOV %ax, 0x64 */
.word 0x64
mov %cs,%ax
@@ -54,6 +61,8 @@
START - Where all the fun begins....
**************************************************************************/
.globl _start
+ .globl start
+start:
_start:
cli
cld
@@ -73,7 +82,11 @@
rep
movsb
opsize
+#ifndef __linux
ljmp $(RELOC>>4),$1f-RELOC /* Jmp to RELOC:1f */
+#else
+ ljmp $(RELOC>>4),$1f-_romstart /* Jmp to RELOC:1f */
+#endif
1:
nop
mov %cs,%ax
@@ -87,6 +100,8 @@
call _real_to_prot
call _main
.globl _exit
+ .globl exit
+exit:
_exit:
call _prot_to_real
#ifdef BOOTROM
@@ -107,6 +122,8 @@
CURRTICKS - Get Time
**************************************************************************/
.globl _currticks
+ .globl currticks
+currticks:
_currticks:
push %ebp
mov %esp,%ebp
@@ -131,6 +148,8 @@
PUTCHAR - Print a character
**************************************************************************/
.globl _putchar
+ .globl putchar
+putchar:
_putchar:
push %ebp
mov %esp,%ebp
@@ -154,6 +173,8 @@
GETCHAR - Get a character
**************************************************************************/
.globl _getchar
+ .globl getchar
+getchar:
_getchar:
push %ebp
mov %esp,%ebp
@@ -174,6 +195,8 @@
ISKEY - Check for keyboard interrupt
**************************************************************************/
.globl _iskey
+ .globl iskey
+iskey:
_iskey:
push %ebp
mov %esp,%ebp
@@ -206,6 +229,8 @@
*/
.globl _setjmp
+ .globl setjmp
+setjmp:
_setjmp:
movl 4(%esp),%ecx
movl 0(%esp),%edx
@@ -220,6 +245,8 @@
ret
.globl _longjmp
+ .globl longjmp
+longjmp:
_longjmp:
movl 4(%esp),%edx
movl 8(%esp),%eax
@@ -239,6 +266,8 @@
___MAIN - Dummy to keep GCC happy
**************************************************************************/
.globl ___main
+ .globl __main
+__main:
___main:
ret
@@ -246,11 +275,17 @@
REAL_TO_PROT - Go from REAL mode to Protected Mode
**************************************************************************/
.globl _real_to_prot
+ .globl real_to_prot
+real_to_prot:
_real_to_prot:
cli
cs
addrsize
- lgdt gdtarg-RELOC
+#ifndef __linux
+ lgdt gdtarg-RELOC
+#else
+ lgdt gdtarg-_romstart
+#endif
mov %cr0, %eax
opsize
or $CR0_PE, %eax
@@ -276,6 +311,8 @@
PROT_TO_REAL - Go from Protected Mode to REAL Mode
**************************************************************************/
.globl _prot_to_real
+ .globl prot_to_real
+prot_to_real:
_prot_to_real:
pop %eax
sub $RELOC,%eax /* Adjust return address */
@@ -293,7 +330,11 @@
* and reload CS register
*/
opsize
- ljmp $(RELOC)>>4, $2f-RELOC
+#ifndef __linux
+ ljmp $(RELOC)>>4, $2f-RELOC
+#else
+ ljmp $(RELOC)>>4, $2f-_romstart
+#endif
2:
/* we are in real mode now
* set up the real mode segment registers : DS, SS, ES